package com.jp.knowledge.adapter.skill;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.model.PositionKnowlegeMode;
import com.jp.knowledge.model.SkillModel;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;

import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/4/20.
 */

public class PositionKnolegeContentAdapter extends RecycleVAdapter<PositionKnowlegeMode.ListBeanX.ListBean> implements View.OnClickListener {

    public PositionKnolegeContentAdapter(Context context, @NonNull List<PositionKnowlegeMode.ListBeanX.ListBean> list) {
        super(context,  list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_skill_content;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        PositionKnowlegeMode.ListBeanX.ListBean data = getData(position);
        TextView itemBtn = holder.get(R.id.skill_item_tv);
        holder.getConvertView().setBackgroundResource(data.isSelect() ? R.color.theme_color : R.color.gray_bg);
        itemBtn.setTextColor(mContext.getResources().getColor(data.isSelect() ? R.color.white : R.color.font_black_think));
        itemBtn.setText(data.getName());
        itemBtn.setTag(position);
        itemBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(itemClickListener != null)
            itemClickListener.onItemClick(mainPositon, (int)v.getTag());
    }

    private int mainPositon;
    public void setMainPositon(int positon){
        this.mainPositon = positon;
    }

    private ItemClickListener itemClickListener;
    public void setItemClickListener(ItemClickListener itemClickListener){
        this.itemClickListener = itemClickListener;
    }
    public interface ItemClickListener{
        void onItemClick(int mainPosition, int subPosition);
    }
}
